//
//  UIBarButtonItem+Extension.swift
//  仿新浪微博
//
//  Created by 陈强 on 17/4/20.
//  Copyright © 2017年 强. All rights reserved.
//

import UIKit

//右击方法点击find call--- 查看调用此方法的地方

extension UIBarButtonItem{
    /// 创建UIBarButtonItem
    ///
    /// - Parameters:
    ///   - title: title
    ///   - fontSize: 字体
    ///   - target: 目标控制器
    ///   - action: 执行点击
    ///   - isBack: 是否带有返回箭头

    convenience init(title:String,fontSize:CGFloat = 16,target:Any,action:Selector,isBack:Bool = false) {
        let btn : UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        
        if isBack {
            let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named:imageName), for: .normal)
            btn.setImage(UIImage(named:imageName + "_highlighted"), for: .highlighted)
            btn.sizeToFit()
        }
        
        btn.addTarget(target, action: action, for: .touchUpInside)
        //实例化uibarbuttonitem
        self.init(customView: btn)
    }
}
